package com.mp.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 *  结果集封装
 * @author: notejava
 * @date: 2020年7月11
 */
@Data
public class Result<T> {
    //1 成功，0 失败
    private T data;
    private Integer code;
    private String msg;
    public Result(){

    }
    public Result(T result,Integer code,String msg){
        this.data=result;
        this.code=code;
        this.msg=msg;
    }
    public static <T> Result<T> success(T data){
        return new Result(data,Code.SUCCESS.getStatus(),Message.SUCCESS_MSG.getMsg());
    }
    public static <T> Result<T> fail(T data){
        return new Result(data,Code.FAIL.getStatus(),Message.FAIL_MSG.getMsg());
    }

    public static <T> Result<T> exception(T data,Integer code,String msg){
        return new Result(data,code,msg);
    }

    public static <T> Result<T> exception(T data,String msg){
        return new Result(data,Code.EXCEPTION.getStatus(),msg);
    }



}
